Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize file names in packages/jest-worker and packages/pretty-format #7316

Merged
merged 12 commits into from
Nov 14, 2018
Merged

Standardize file names in packages/jest-worker and packages/pretty-format #7316

merged 12 commits into from
Nov 14, 2018

Conversation

matmalkowski
Copy link
Contributor

Summary

This is part of #4969 - standardizes file names in packages/jest-worker and packages/pretty-format under Facebook naming conventions

Test plan

I've run yarn test and although its not passing, I'm getting same test failures on master

@matmalkowski matmalkowski changed the title Rename packages 2 Standardize file names in packages/jest-worker and packages/pretty-format Nov 1, 2018
@SimenB SimenB requested a review from thymikee November 5, 2018 23:25
CHANGELOG.md Outdated
@@ -95,6 +95,8 @@
- `[docs]` Add correct default value for `testUrl` config option ([#7277](https://github.com/facebook/jest/pull/7277))
- `[jest-util]` [**BREAKING**] Remove long-deprecated globals for fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
- `[docs]` Remove duplicate code in `MockFunctions` ([#7297](https://github.com/facebook/jest/pull/7297))
- `[jest-haste-map]` Standardize filenames ([#7316](https://github.com/facebook/jest/pull/7316))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest-haste-map -> jest-worker

@@ -9,7 +9,7 @@

import type {Config, Printer, Refs} from 'types/PrettyFormat';

import escapeHTML from './escape_html';
import escapeHTML from './escapeHTML';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename the rest of the files in pretty-format? There's quite a bunch of left

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I might have missed some, could you point out what files are left? I thought that the ones in /src/ have multiple exports per file, hence I left files with snake_case

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to rename every file that doesn't stick to the convention.
E.g.

packages/pretty-format/src/__tests__/asymmetric_matcher.test.js
packages/pretty-format/src/plugins/asymmetric_matcher.js

to have names as variables:

import AsymmetricMatcher from './plugins/asymmetric_matcher';
import ConvertAnsi from './plugins/convert_ansi';
import DOMCollection from './plugins/dom_collection';
import DOMElement from './plugins/dom_element';
import Immutable from './plugins/immutable';
import ReactElement from './plugins/react_element';
import ReactTestComponent from './plugins/react_test_component';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the './plugins/asymmetric_matcher' has 3 exports, so according to those:

All folders -> kabab-case
All files that export a single Class -> CapitalizeCase
All files that export a single function -> camelCase
All other files -> underscore_case

its falling into the underscore_case?

Copy link
Collaborator

@thymikee thymikee Nov 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake in interface, they shouldn't expose serialize and test directly, as they do it in a default export – and we only use it that way. You can remove those named exports. cc @pedrottimark

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thymikee Great, I will redo the exports and fix those files, thanks 👍

@matmalkowski
Copy link
Contributor Author

@thymikee Hey, I've renamed plugins, but now I got quite a lot of test failures, related to the fact that I removed the exports for test / serialize from them, and seems like they are still accessed directly: plugins[p].test is not a function. Any tip on how should I proceed with this?

@thymikee
Copy link
Collaborator

Oh, that's interesting. For now let's just bring back the exports if they're just for testing

@matmalkowski
Copy link
Contributor Author

@thymikee 👍 reverted the mentioned exports and now everything is passing

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -11,7 +11,7 @@

import React from 'react';
import Immutable from 'immutable';
import {getPrettyPrint} from './expect_util';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getPrettyPrint now only exports a single fn with the same name. Since there's no other exports there, maybe it's worth to change it to default export?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the changes, not sure if that's what you meant, please take a look 👍

@thymikee thymikee merged commit 06bf664 into jestjs:master Nov 14, 2018
@thymikee
Copy link
Collaborator

Thanks for sticking with me!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants